<?php
namespace app\common\model;

use think\Db;
use think\Model;

/**   YSF
 *    屏显模式 Model
 *    Date: 2018/9/4
 * Class ScreenModel
 * @package app\common\model
 */
class ScreenModel extends Model
{
    // 表名
    protected $dbName = 'equipment_screen_mode_config';

    // 列表查询
    public function getAll($where=[], $page=1, $pageSize=100, $field='*',$order='sort ASC,create_time DESC')
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->field($field)
                    ->page($page, $pageSize)
                    ->order($order)
                    ->select();
//        echo Db::name($this->dbName)->getLastSql();die();
        return $result;
    }

    // 数量统计
    public function getCount($where=[])
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->count();
        return $result;
    }

    // 单条查询
    public function getOne($where, $field='*')
    {
        $result = Db::name($this->dbName)->where($where)->field($field)->find();
        return $result;
    }

    // 添加
    public function add($data)
    {
        $result = Db::name($this->dbName)->insertGetId($data);
        return $result;
    }

    // 修改
    public function edit($where, $data)
    {
        $result = Db::name($this->dbName)->where($where)->update($data);
        return $result;
    }

}